﻿import Taro, { Component } from '@tarojs/taro'
import { Swiper, SwiperItem, Image, View, Text, Canvas } from '@tarojs/components'
import '../../assets/common.scss'
import CommonJs from '../../utils/common'
import './lottery.scss'
import Hearder from '../index/hearder'
export default class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      qun_date:'',
      pageheight:0,
      navindex:9,//用于判断导航选中
      qid:Taro.getStorageSync('dateinfo').qid,
      color:[0,0,0,0,0,0,0,0,0,0,0,0],
      clickLuck:'',
      interval:null,
      intervals:null,
      luckPosition:'',//中奖位置
      result:[],
      paymentTypeName:[],
      winninginfo:[],//中奖信息
      newcode:'',
      newcodes:'',
      luckpoint:{},//幸运值 
      luckyDrawId:'',
      dates:[{str:'',path:'',info:'',type:0}],//抽奖弹窗信息
      intime:50,//值越大旋转时间越长  即旋转速度
      zojn:0,//抽奖弹窗
      ruletype:0,//规则弹窗
      rulelist:[],//规则信息
      rotate:45,
      rotate1:-135,
      regTypes:false,
      jinduto:1,
      shopId:'',
      dealerId:'',
      lcList:[],
      lcSet:{luckyDrawFrequencyId:"",paymentTypeId:""},
      lczj:0,//连抽中奖弹窗
      frequency:1,//连抽次数
      iszy:0,
      annu:['https://minichat.g2ma.com/kedouimg/live09.png','https://minichat.g2ma.com/kedouimg/live22.png','https://minichat.g2ma.com/kedouimg/kedoubi.png','https://minichat.g2ma.com/kedouimg/live20.png']
    }
  }
  config = {
    navigationBarTitleText: '加载中'
  }

  componentWillMount () {
    var _this = this
    Taro.getSystemInfo({
      success:function(res){
        _this.setState({
          pageheight: res.windowHeight
        })
      }   
    })
    _this.getquninfo()
    _this.getShop()
    var ciszy=Taro.getStorageSync('guide');
    if(ciszy>1){
    	 this.setState({
	      iszy:3,
	      jinduto:0
	    })
    }
    else{
	    this.setState({
	      iszy:ciszy
	    })
	  }
  }
  componentDidShow () {
    var _this = this
    var regTypes = _this.$scope.data.regTypes
    if (regTypes) {
      _this.getlotteryV(_this.state.luckyDrawId)
    }
  }
  componentWillUnmount () {
    var _this = this
    clearInterval(_this.interval)
    clearInterval(_this.intervals)
  }
  getShop(){
    var _this = this
    var dates = {
      clusterId: _this.state.qid
    }
    CommonJs.ajaxRequest('/clusterShop/getClusterShopByclusterId',dates,'GET',function(res){
      // console.log(JSON.stringify(res))
      _this.setState({
        shopId: res.content.shopId,
        dealerId: res.content.dealerId
      },function(){
        _this.getdata()
        _this.drawProgressbg()
        // this.getwinning()
        _this.getMyLuckPoint()
        _this.getName()
      })
    })
  }
  getsuoy(){
    var _this = this
    // _this.getwinning()
    _this.getMyLuckPoint()
    _this.getlotteryV(_this.state.luckyDrawId)
  }
  getName(){
    var _this = this
    var dates = {
      shopId:_this.state.shopId
    }
    CommonJs.ajaxRequest('/luckydraw/getLuchkDrawShopIdList',dates,'GET',function(res){
      // console.log(JSON.stringify(res))
      Taro.setNavigationBarTitle({title:res.content[0].name})
    },'noloading')
  }
  getrule(){
    var _this = this
    var dates = {
      shopId:_this.state.shopId,
      pageSize:12,
      pageNumber:1,
      status:1,
      luckyDrawId:_this.state.luckyDrawId
    }
    CommonJs.ajaxRequest('/prize/queryPrize',dates,'GET',function(res){
      // console.log(JSON.stringify(res))
      if (res.code != 300) {
        _this.setState({
          clickLuck:'clickLuck',
          rulelist:res.content.result,
          ruletype:1,
          jinduto:0
        })
      } else {
        _this.setState({
          clickLuck:'clickLuck'
        })
        Taro.showToast({
          title:res.msg,
          icon: 'none',
          duration: 2000
        })
      }
    },'noloading','noret')
  }
  getlc(){
  	
  	var dates = {
      luckyDrawId:this.state.luckyDrawId
    }
  	var _this=this;
  	CommonJs.ajaxRequest('/luckydrawfrequency/getFrequency',dates,'GET',function(res){
  		if (res.code != 300) {
  			if(res.content.length>0){
	  			 _this.setState({
	          lcList:res.content,
	          clickLuck:'clickLuck',
	          ruletype:1,
	          jinduto:0,
	          lcSet:{luckyDrawFrequencyId:res.content[0].id,paymentTypeId:1}
	        })
	  		}
  			else{
  				Taro.showToast({
	          title:"商家未开通连抽",
	          icon: 'none',
	          duration: 2000
	        })
  			}
  		}
  		else{
  			Taro.showToast({
          title:res.msg,
          icon: 'none',
          duration: 2000
        })
  		}

  	})
  	
  }
  lcSet(val,type){
  	var obj=this.state.lcSet;
  	
  	if(type==1){
  		obj.luckyDrawFrequencyId=val;
  	}
  	else{
  		obj.paymentTypeId=val;
  	}
  	this.setState({
      lcSet:obj
    })
  }
  lcClose(){
  	this.setState({
	    ruletype:0,
	    jinduto:1
	  })
  }
  lcStart(){
  	var obj=this.state.lcSet;
  	this.clickLucks(obj.paymentTypeId,obj.luckyDrawFrequencyId)	
  }
  lcZhongjiangClose(){
  	this.setState({
	    lczj:0,
	    jinduto:1
	  })
  	var iszy=Taro.getStorageSync('guide');
  	if(iszy>0){
  		this.guide(4)
  	}
  	
  }
  stopLuck(which, index ,time, splittime){
    //which:中奖位置 index:当前位置 time:时间标记 splittime:每次增加的时间 值越大减速越快
    var _this = this
    //值越大出现中奖结果后减速时间越长
    var color = _this.state.color
    setTimeout(function () {
      //重置前一个位置
      
      if (index > 15) {
        index = 0
        color[15] = 0
      } else if (index != 0) {
        color[index - 1] = 0
      }
      //当前位置为选中状态
      color[index] = 1
      _this.setState({
        color: color
      })
      //如果旋转时间过短或者当前位置不等于中奖位置则递归执行
      //直到旋转至中奖位置
      console.log(which+"///ssssss")
      if (!which) {//time<400||index != which 
        //越来越慢
        splittime++
       // time += splittime
        //当前位置+1
        index++ 
        console.log(index+"/"+which)
        _this.stopLuck(which, index, time, splittime)
      } else {
      	console.log("ssssss")
        var result = _this.state.result
        var str = _this.stimgcl(result[which])//得到当前选中图片路径
        var info = _this.sttxtcls(result[which])//得到按钮信息
        // console.log(str+'112233'+info)
        _this.getsuoy()//重新刷新数据
        //1秒后显示弹窗
        // console.log(_this.state.newcodes+'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy')
        setTimeout(function () {
        	
        	if(_this.state.frequency==1){//连抽次数
	          if (str != 'https://minichat.g2ma.com/kedouimg/live11.png') {
	            //中奖
	            var dates=[];
	            dates[0] = {
	              str:str,
	              path:'https://minichat.g2ma.com/kedouimg/zhongjiang.png',
	              info:info,
	              type:1
	            }
	            _this.setState({
	              zojn:1,
	              jinduto:0,
	              clickLuck: 'clickLuck',
	              dates:dates,
	              newcode:_this.state.newcodes
	            })
	          } else {
	            //未中奖
	            var dates=[];
	            dates[0] = {
	              str:str,
	              path:'https://minichat.g2ma.com/kedouimg/zhongjiang1.png',
	              info:info,
	              type:0
	            }
	            _this.setState({
	              zojn:1,
	              jinduto:0,
	              clickLuck: 'clickLuck',
	              dates:dates,
	              newcode:_this.state.newcodes
	            })
	          }
	        }
        	else{
        		_this.setState({
              lczj:1,
              jinduto:0,
              clickLuck: 'clickLuck',
              newcode:_this.state.newcodes
            })
        	}
        	
        }, 1000)
       
      }
    }, time) 
   
  }
  lotteryCom(type){
    var _this = this
    _this.setState({
      iszy: 0
    })
    var clickLuck = _this.state.clickLuck
    if (clickLuck == 'clickLuck') {
      clearInterval(_this.intervals)
      var annu = _this.state.annu
      if (type == 3) {
        var annus = 'https://minichat.g2ma.com/kedouimg/live20c.png'
        annu[type] = annus
      } else if (type == 2) {
        var annus = 'https://minichat.g2ma.com/kedouimg/kedoubi1.png'
        annu[type] = annus
      } else if (type == 1) {
        var annus = 'https://minichat.g2ma.com/kedouimg/live22c.png'
        annu[type] = annus
      } else if (type == 0) {
        var annus = 'https://minichat.g2ma.com/kedouimg/live09c.png'
        annu[type] = annus
      }
      _this.setState({
        annu:annu,
        clickLuck:''//设置按钮不可点击
      })
      setTimeout(() => {
      	
        _this.lotteryComs(type)
      },400)
    } else {
      return
    }
  }
  lotteryComs(type){
    var _this = this
    var annu = _this.state.annu
    if (type == 3) {
      var annus = 'https://minichat.g2ma.com/kedouimg/live20.png'
      annu[type] = annus
    } else if (type == 2) {
      var annus = 'https://minichat.g2ma.com/kedouimg/kedoubi.png'
      annu[type] = annus
    } else if (type == 1) {
      var annus = 'https://minichat.g2ma.com/kedouimg/live22.png'
      annu[type] = annus
    } else if (type == 0) {
      var annus = 'https://minichat.g2ma.com/kedouimg/live09.png'
      annu[type] = annus
    }
    _this.setState({
      annu:annu,
      color:[0,0,0,0,0,0,0,0,0,0,0,0]
    },function(){
      _this.clickLuck(type)
    })
  }
  clickLuckcl(name){
    var _this = this
    var str = '该商家未开启！'
    var paymentTypeId = ''
    var paytype = _this.state.paymentTypeName
    for (var i = 0; i < paytype.length; i++) {
      if (paytype[i].paymentTypeName == name) {
        str = ''
        if (paytype[i].myAmount < paytype[i].amount) {
          str = name+'不足'
        }
        paymentTypeId = paytype[i].paymentTypeId
      }
    }
    // console.log(paymentTypeId+'99999999')
    if (str != '') {
      Taro.showToast({
        title:str,
        icon: 'none',
        duration: 2000
      })
      _this.setState({
        clickLuck:'clickLuck'
      })
    } else {
      _this.clickLucks(paymentTypeId)
    }
  }
  clickLucks(paymentTypeId,luckyDrawFrequencyId){
    var _this = this
    var dates = {
      type:2,
      verifyCode:_this.state.newcode,
      paymentTypeId:paymentTypeId
    }
    if(luckyDrawFrequencyId){
    	
    	dates.luckyDrawFrequencyId=luckyDrawFrequencyId;
    }
    Taro.showLoading({title: '准备中'})
    CommonJs.ajaxRequest('/prize/markLuckDraw',dates,'GET',function(res){
      //console.log(JSON.stringify(res))
      _this.setState({
        ruletype:0
      })
      if (res.code != 300) {
      		
        if (res.code == 201) {
          _this.setState({
            newcodes:res.content.shopVerifyCode
          })
        }
        var index = 0
        var color = _this.state.color
        var intime = _this.state.intime
        console.log("ddddddddddd11111")
        _this.interval = setInterval(function () {
          if (index > 15) {
            index = 0
            color[15] = 0
          } else if (index != 0) {
            color[index - 1] = 0
          }
          color[index] = 1
          _this.setState({
            color:color
          })
          index++
        }, intime)
        //旋转时间  设为1.5秒
        var stoptime = 1500
        setTimeout(function () {
          _this.getstatus()
        }, stoptime)
      } 
      else{
      	if(luckyDrawFrequencyId){
      		_this.setState({
	          clickLuck:'clickLuck',
	          jinduto:1
	        })
      		setTimeout(function () {
	          Taro.showToast({
		          title:res.msg,
		          icon: 'none',
		          duration: 2000
		        })
	        },800)
        	
        }
      }
    },'noloading','noret')
  }
  clickLuck(types){
    //抽奖
    var _this = this
    //清空计时器
    clearInterval(_this.interval)
    if (types == 0) {
    	
      //_this.getrule() 查看奖项  换成 连抽选择
      _this.getlc();
    } else {
      var str = ''
      if (types == 1) {
        str = '住票'
      } else if (types == 2){
        str = '蝌蚪币'
      } else if (types == 3) {
        str = '积分'
      }
      _this.clickLuckcl(str)
    }
  }
  
  stop(which,intime){
    var _this = this
    //清空计数器
    clearInterval(_this.interval)
    //初始化当前位置
    var current = -1
    var color = _this.state.color;
    for (var i = 0; i < color.length; i++) {
      if (color[i] == 1) {
        current = i
      }
    }
    //下标从1开始 
    var index = current + 1
    _this.stopLuck(which, index, intime, 10); 
  }
  getdata(){
    //获取奖项
    var _this = this
    var dates = {
      pageSize:16,
      pageNumber:1,
      shopId:_this.state.shopId,
      luckyStatus:1,
      luckyDrawId:0
    }
    CommonJs.ajaxRequest('/prize/queryPrize',dates,'GET',function(res){
      // console.log(JSON.stringify(res)+'111111111')
      var luckyDrawId = res.content.result[0].luckyDrawId
      var jia = res.content.result
      var jiaLen = jia.length
      if (jiaLen >= 16) {
      	_this.setState({
          luckyDrawId:luckyDrawId,
          result:jia
        })
        _this.getlotteryV(luckyDrawId)
        _this.checkewm(luckyDrawId)
        
      } else {
        Taro.showModal({
          title: '提示',
          content: '奖项不足,等商家完善!',
          showCancel: false,
          success: function (res) {
            if (res.confirm) {
              //设置按钮可以点击
              _this.setState({
                luckyDrawId:luckyDrawId,
                clickLuck:'clickLuck'
              })
              Taro.navigateBack({ delta: 1 })
            }
          }
        })
      }
    })
  }
  getstatus(){
    var _this = this
    _this.intervals = setInterval(function () {
      var dates = {
        verifyCode:_this.state.newcode
      }
      CommonJs.ajaxRequest('/prizeorder/getPrizeLuckyOrder',dates,'GET',function(res){
        //console.log(JSON.stringify(res)+'111111111')
        if (res.code != 300) {
          if (res.code == 201) {
          		if (res.content.frequency>1) {
	            	_this.setState({
	                dates:res.content.prizeOrderList,
	                frequency:res.content.frequency
	              })
	          	}
          		else{
          			_this.setState({
	                frequency:res.content.frequency
	              })
          		}
          	  var prizeId = res.content.prizeOrderList[0].prizeId
	            var result = _this.state.result
	            var newcodes=res.content.shopVerifyCode;
	            if(newcodes){
	            	_this.setState({
	                newcodes:newcodes
	             })
	            }
	            for(var i = 0; i < result.length; i++){
	              if (result[i].id == prizeId) {
	                _this.setState({
	                  luckPosition:i
	                },function(){
	                  var intime = _this.state.intime
	                  var luckPosition = _this.state.luckPosition
	                  console.log("中奖结果："+luckPosition)
	                  _this.stop(luckPosition,intime)
	                })
	              }
	            }
          }
        }
      },'noloading','noret')
    },1000)
  }
  checkewm(luckyDrawId){
    //生成二维码
    var _this = this
    var dates = {
      shopId:_this.state.shopId,
      luckyDrawId:luckyDrawId
    }
    CommonJs.ajaxRequest('/shopverifycode/getLuckyShopVerifyCode',dates,'GET',function(res){
      // console.log(JSON.stringify(res)+'111111111')
      var newcode = res.content
      _this.setState({
        newcode:newcode,
        clickLuck:'clickLuck'
      })
    })
  }
  getlotteryV(luckyDrawId){
    //获取抽奖方式的金额和可用余额
    var _this = this
    var dates = {
      shopId:_this.state.shopId,
      luckyDrawId:luckyDrawId
    }
    CommonJs.ajaxRequest('/LuckyPaymentType/getLuckyPaymentTypeByUserId',dates,'GET',function(res){
      // console.log(JSON.stringify(res)+'111111111')
      var paymentTypeName = res.content
      _this.setState({
        paymentTypeName:paymentTypeName
      })
    },'noloading')
  }
  getwinning(){
    //获取中奖信息
    var _this = this
    var dates = {
      shopId:_this.state.shopId,
      pageSize:1000,
      pageNumber:1,
      dealerId:_this.state.dealerId
    }
    CommonJs.ajaxRequest('/prizeorder/queryPrizeOrder',dates,'GET',function(res){
      // console.log(JSON.stringify(res)+'111111111')
      var winninginfo = ['你们还没有中奖呦，赶快抽奖吧！']
      var result = res.content.result
      // console.log(JSON.stringify(winninginfo)+'333333')
      if (result.length > 0) {
        winninginfo = result
      }
      // console.log(JSON.stringify(winninginfo)+'222222')
      _this.setState({
        winninginfo:winninginfo
      })
    },'noloading')
  }
  getMyLuckPoint(){
    //获取幸运值
    var _this = this
    var dates = {
      shopId:_this.state.shopId
    }
    // console.log(JSON.stringify(dates)+'111111111')
    CommonJs.ajaxRequest('/luckPoint/getMyLuckPoint',dates,'GET',function(res){
      // console.log(JSON.stringify(res)+'111111111')
      _this.setState({
        luckpoint:res.content
      })
      _this.luckpointcl(res.content)
    },'noloading')
  }
  luckpointcl(luckpoint){
    // transform:rotate(45deg);
    var _this = this
    if (luckpoint.times != undefined) {
      var a = 2 / luckpoint.luckPointMax
      var b = a * luckpoint.times
      var c = b.toFixed(12)
      // console.log(c)
      if (luckpoint.times <= luckpoint.luckPointMax) {
        _this.drawCircle(c)
      } else {
        _this.drawCircle(2)
      }
    }
  }
  clwinning(item){
    var str = ''
    if (item.userName != undefined){
      var userNames = item.userName
      var userName = userNames.substr(0,2)
      str = userName+'**** '+CommonJs.FormatDate(item.createAt,3)+' ---------'+item.rank+'等奖'
    } else {
      str = item
    }
    return str
  }
  stimgcl(obj){
  	
    var str = ''
    if(obj){
	    if (obj.prizeType == 1) {
	      if (obj.commodityLogo != null || obj.commodityLogo != '') {
	        str = obj.commodityLogo
	      }
	    } else if (obj.prizeType == 2 || obj.prizeType == 5 || obj.prizeType == 6) {
	      if (obj.prizeLogo != null || obj.prizeLogo != '') {
	        str = obj.prizeLogo
	      }
	    } else if (obj.prizeType == 3) {
	      if (obj.logo != null || obj.logo != '') {
	        str = obj.logo
	      }
	    } else if (obj.prizeType == 4) {
	        str = 'https://minichat.g2ma.com/kedouimg/live11.png'
	    }
	  }
    return str
  }
  sttxtcl(obj){
    var str = ''
    if(obj){
	    if (obj.prizeType == 1 || obj.prizeType == 3) {
	      //str = '商品'
	      str=obj.commodityName
	    } else if (obj.prizeType == 2) {
	      str = '积分×'+obj.credit
	    } else if (obj.prizeType == 4) {
	      str = '谢谢参与'
	    } else if (obj.prizeType == 5) {
	        str = '蝌蚪币×'+obj.credit
	    } else if (obj.prizeType == 6) {
	        str = '住票×'+obj.credit
	    }
	  }
    return str
  }
  sttxtcls(obj){
    var str = ''
    if (obj.prizeType == 1 || obj.prizeType == 3) {
     //str = '商品'
	    str=obj.commodityName
    } else if (obj.prizeType == 2) {
      str = obj.credit+'积分'
    } else if (obj.prizeType == 4) {
      str = '谢谢参与'
    } else if (obj.prizeType == 5) {
        str = obj.credit+'蝌蚪币'
    } else if (obj.prizeType == 6) {
        str = obj.credit+'住票'
    }
    return str
  }
  paytypenamecl(paytype,type,zifu,zole){
    var str = ''
    if (zifu == 'mymoney'){
      str = '未开启'
    } else if (zifu == 'money') {
      str = 0
    }
    if (paytype.length > 0) {
      for (var i = 0; i < paytype.length; i++) {
        if (paytype[i].paymentTypeId == type || paytype[i].paymentTypeName == zole) {
          if (zifu == 'mymoney'){
            str = paytype[i].myAmount
          } else if (zifu == 'money') {
            str = paytype[i].amount
          }
        }
      }
    }
    return str
  }
  rulecl(obj){
    var str = ''
    if (obj.prizeType == 1) {
      str = obj.goodsName+' 商品'
    } else if (obj.prizeType == 2) {
      str = obj.credit+' × 积分'
    } else if (obj.prizeType == 3) {
      str = obj.projectName
    } else if (obj.prizeType == 4) {
      str = '谢谢参与 '
    } else if (obj.prizeType == 5) {
        str = obj.credit+' × 蝌蚪币'
    } else if (obj.prizeType == 6) {
        str = obj.credit+' × 住票'
    }
    return str
  }
  zojncolse(){
    var _this = this
    _this.setState({
      zojn:0,
      jinduto:1
    })
    var iszy=Taro.getStorageSync('guide');
  	if(iszy>0){
  		this.guide(4)
  	}
  }
  rulecolse(){
    var _this = this
    _this.setState({
      ruletype:0,
      jinduto:1
    })
  }
  open(url,type){
    this.$preload({
      type:type
    })
    CommonJs.open(url);
  }
  getquninfo(){
    var _this=this;
    var date1={id:_this.state.qid}
    CommonJs.ajaxRequest('/cluster/getEntityAndLoginId',date1,'GET',function(res){
        var query=Taro.createSelectorQuery()
        query.select('.qun-bgbanner').boundingClientRect(function(rect){
          var height=_this.state.pageheight
          _this.setState({
              qun_date: res.content,
              pageheight:height-rect.height
          })
        }).exec();
    })
  }
  drawProgressbg(){
    var ctx = Taro.createCanvasContext('canvasProgressbg')
    ctx.setLineWidth(6)// 设置圆环的宽度
    ctx.setStrokeStyle('#d1b864') // 设置圆环的颜色color="#d1b864"
    ctx.setLineCap('round') // 设置圆环端点的形状
    ctx.beginPath()//开始一个新的路径
    ctx.arc(41, 41, 30, 0, 2 * Math.PI, false)
    //设置一个原点(100,100)，半径为90的圆的路径到当前路径
    ctx.stroke()//对当前路径进行描边
    ctx.draw()
  }
  drawCircle(step){
    // console.log(step)
    var context = Taro.createCanvasContext('canvasProgress');
    // 设置渐变
    // var gradient = context.createLinearGradient(200, 100, 100, 200)
    // gradient.addColorStop("0", "#2661DD")
    // gradient.addColorStop("0.5", "#40ED94")
    // gradient.addColorStop("1.0", "#5956CC")
    
    context.setLineWidth(6)
    context.setStrokeStyle('#88cf29')//color="#88cf29"
    context.setLineCap('round')
    context.beginPath(); 
    // 参数step 为绘制的圆环周长，从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ，结束角 通过改变 step 的值确定
    context.arc(41, 41, 30, -Math.PI / 2, step * Math.PI - Math.PI / 2, false)
    context.stroke()
    context.draw()
  }
  opendetails(url){
    this.$preload({
      regType:1
    })
    CommonJs.openTo(url)
  }
  onShareAppMessage(res){
    let title = '"'+this.state.qun_date.name+'社群"，点击进入，和我一起参加活动吧'
    let path = '/pages/activity/activity?scene='+this.state.qun_date.id
    let imageUrl = this.state.qun_date.photo
    return CommonJs.onShareAppMessage(title, path, imageUrl)
  }
  guide(val){
  	if(val>1){
  		console.log(val+"/ddddd")
  		this.setState({
	      iszy:val,
	      jinduto:0
	    })
  	}
  	else{
	  	this.setState({ 
	      iszy: val,
	      jinduto:1
	    })
	  }
  	Taro.setStorage({key:'guide',data:val})
  	
  }
  closezy(){
  	if(this.state.iszy>0){
  		CommonJs.ajaxRequest('/guide/updateGuide','','GET',function(res){})
  		this.guide(0);
  	}
  }
  render () {
    const annu = this.state.annu
    const color = this.state.color
    const result = this.state.result
    const paymentTypeName = this.state.paymentTypeName
    const winninginfo = this.state.winninginfo
    const luckpoint = this.state.luckpoint
    const dates = this.state.dates
    const rulelist = this.state.rulelist
    const list_date = this.state.qun_date
      //中奖轮播
      // <View className='qun-cjzojn'>
      //   <Image className='choujianbg1' src='https://minichat.g2ma.com/kedouimg/zjxx.png'></Image>
      //   <View className='qun-cjinfos'>
      //     <View className='qun-choujian'>
      //       <Swiper
      //         className='qun-choujiangs'
      //         vertical='true'
      //         autoplay='true'
      //         circular='true'
      //         interval='2000'>
      //         {winninginfo.map((item, index) => ( 
      //         <SwiperItem>
      //           <View className='qun-zhongjiangs'>{this.clwinning(item)}</View>
      //         </SwiperItem>
      //         ))}
      //       </Swiper>
      //     </View>
      //   </View>
      // </View>
      // 住票抽奖按钮
      // <View className='qun-cjguze' onClick={this.lotteryCom.bind(this,1)}>
      //   <Image className='qun-cjguzeimg' mode='' src={annu[1]}></Image>
      //   <View className='qun-cjjner qun-fenshu1'>
      //     <Image className='qun-cjjnerimg' mode='' src='https://minichat.g2ma.com/kedouimg/live03.png'></Image>
      //     <View className='qun-cjsuzi qun-cjzis'>{this.paytypenamecl(paymentTypeName,3,'money','住票')}</View>
      //   </View>
      // </View>
    let lcList = this.state.lcList
    return (
    	
      <View className='page'>
      	
      	<View className='lc-box' style={this.state.ruletype == 1 ? 'display:block;' : 'display:none;'} >
      		<View className='lc-close' onClick={this.lcClose.bind(this)}><Image mode='widthFix' src='https://minichat.g2ma.com/kedouimg/close1.png'></Image></View>
      		<View className='qun-guizebiao'>选择连抽方式</View>
          <View className='lc-dl'>
          		{lcList.map((item, index) => (
	        		<Text className={this.state.lcSet.luckyDrawFrequencyId== item.id?'lc-dd lc-cur':'lc-dd'} onClick={this.lcSet.bind(this,item.id,1)}>{item.frequency}连抽</Text>
	        		))}
	        </View>
	        <View className='lc-dl'>
	        		<Text className={this.state.lcSet.paymentTypeId == 1?'lc-dd lc-cur':'lc-dd'} onClick={this.lcSet.bind(this,1,2)}>积分</Text>
	        		<Text className={this.state.lcSet.paymentTypeId == 2?'lc-dd lc-cur':'lc-dd'} onClick={this.lcSet.bind(this,2,2)}>蝌蚪币</Text>
	        </View>
	        <View className='lc-btn' onClick={this.lcStart.bind(this)}>我要连抽</View>
        </View>
        
        <View className='lc-zhongjiang' style={this.state.lczj == 1 ? 'display:block;' : 'display:none;'} onClick={this.lcZhongjiangClose.bind(this)}>
          <View className='lc-zhongjiang-goods'>
          	{dates.map((item, index) => (
          	<View className='lc-zhongjiang-li'>
          			<View className='lc-zhongjiang-img'><Image src={this.stimgcl(item.prize)} mode='widthFix'></Image></View>
          			<Text className="lc-zj-name">{this.sttxtcl(item.prize)}</Text>
          	</View>
          	))}
          	<View className='lc-zhongjiang-li' style={dates.length != this.state.frequency ? 'display:block;' : 'display:none;'} >
          			<Image src='https://minichat.g2ma.com/kedouimg/tdbuser6.png' mode='widthFix'></Image>
          			<Text className="lc-zj-name">&nbsp;</Text>
          	</View>
          </View>
          <View className='lc-btn' style="width:50%;margin:20px auto 0 auto;display:none;" onClick={this.open.bind(this,'/pages/pkgo/winningrecord')}>查看奖品</View>
        </View>
        
        
        
      
        <ScrollView className='qun-guzes' scrollY='true' style={this.state.ruletype == 1 ? 'display:none;' : 'display:none;'} onClick={this.rulecolse.bind(this)}>
          <View className='qun-guizebiao'>规则表</View>
          <View className='qun-guzelist'>
            <View className='qun-guzeul'>
              {rulelist.map((item, index) => (
              <View className='qun-guzeli'>
                <Image className='qun-guzeliimg' src={this.stimgcl(item)}></Image>
                <View className='qun-guzeinfo'>{this.rulecl(item)}</View>
              </View>
              ))}
            </View>
          </View>
        </ScrollView>
      
        <View className='qun-zhongjiangino' style={this.state.zojn == 1 ? 'display:block;' : 'display:none;'} onClick={this.zojncolse.bind(this)}>
          <View className='qun-zhongjiangin1'>
            <Image className='qun-zongjiasmg' mode='widthFix' src={dates[0].path}></Image>
            <View className='qun-zhongjiangin2'>
              <View className='qun-zhongjiangin4'>
                <Image className='qun-cjxnynimg' src={dates[0].str}></Image>
              </View>
              <View className='qun-zhongjiangannu' style={dates[0].type == 1 ? 'display:block;' : 'display:none;'}>{dates[0].info}</View>
            </View>
          </View>
        </View>
        
        	
        
        
        <View className='qun-bgbanner'>
          <Hearder propItem={list_date} porpNav={this.state.navindex} propGuite={this.state.iszy} onHandOpen={this.open.bind(this)}></Hearder>
        </View>
        <View className='qun-choujianbg' style={'height:'+this.state.pageheight+'px'}>
          <Image className='choujianbg' src='https://minichat.g2ma.com/kedouimg/live01.png'></Image>
          <View className='qun-choujiacont'>
           <View className='qun-cjtite'>
            <View className='qun-cjtites'>
              <View className='qun-cjtitesrig'>
                <View className='qun-cjti1'>
                  <View className='qun-cjjfen1'>
                    <Text className='qun-cjjfen2'>积分</Text>
                    <View className='qun-cjjfen3'>
                      <Image className='qun-cjxnynimg' src='https://minichat.g2ma.com/kedouimg/jekuan.png'></Image>
                      <View className='qun-texts1'>{this.paytypenamecl(paymentTypeName,1,'mymoney','积分')}</View>
                    </View>
                  </View>
                  <View className='qun-cjjfen1 qun-cjjfenleft1'>
                    <Text className='qun-cjjfen2'>蝌蚪币</Text>
                    <View className='qun-cjjfen3'>
                      <Image className='qun-cjxnynimg' src='https://minichat.g2ma.com/kedouimg/jekuan.png'></Image>
                      <View className='qun-texts1'>{this.paytypenamecl(paymentTypeName,2,'mymoney','住币')}</View>
                    </View>
                  </View>
                </View>
              </View>
              <View className='qun-chonzi' onClick={this.opendetails.bind(this,'/pages/my/recharge')}>充值</View>
            </View>
           </View>
           <View className='qun-cjtite1'></View>
           <View className='qun-cjtite2'>
            <View className='qun-cjzhnpn'>
              <View className='container'>
                <View className='frameview'>
                  <View className='frameviewcen'>
                    <View className='frameviewcens'>
                      <Image className='frameitemimg' src='https://minichat.g2ma.com/kedouimg/choujiangdt.png'></Image>
                      <View className='framejndu'>
                        <View className='framejndu1'>
                          <Image className='framejnduimg' src='https://minichat.g2ma.com/kedouimg/xingyunzhi.png'></Image>
                          <View className='framejndu2'>
                            <View className='framejndu3'>
                              <View className='framejndu5'>{luckpoint.times}/{luckpoint.luckPointMax}</View>
                              <View className='framejndu4'>
                                <View className='progress_box' style={this.state.jinduto == 1 ? 'display:block' : 'display:none'}>
                                  <Canvas className='progress_bg' canvasId='canvasProgressbg'></Canvas>
                                  <Canvas className='progress_canvas' canvasId='canvasProgress'></Canvas> 
                                </View>
                              </View>
                            </View>
                          </View>
                        </View>
                      </View>
                    </View>
                  </View>
                  <View className='framerow'>
                    <View className={color[0] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[0] ? this.stimgcl(result[0]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[0] ? this.sttxtcl(result[0]) : ''}</View></View>
                    </View>
                    <View className={color[1] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[1] ? this.stimgcl(result[1]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[1] ? this.sttxtcl(result[1]) : ''}</View></View>
                    </View>
                    <View className={color[2] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[2] ? this.stimgcl(result[2]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[2] ? this.sttxtcl(result[2]) : ''}</View></View>
                    </View>
                    <View className={color[3] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[3] ? this.stimgcl(result[3]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[3] ? this.sttxtcl(result[3]) : ''}</View></View>
                    </View>
                    <View className={color[4] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[4] ? this.stimgcl(result[4]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[4] ? this.sttxtcl(result[4]) : ''}</View></View>
                    </View>
                    <View className={color[5] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[5] ? this.stimgcl(result[5]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[5] ? this.sttxtcl(result[5]) : ''}</View></View>
                    </View>
                  </View>
                  <View className='framerow'>
                    <View className={color[15] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[15] ? this.stimgcl(result[15]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[15] ? this.sttxtcl(result[15]) : ''}</View></View>
                    </View>
                    <View className='frameitem' style='display:none'></View>
                    <View className='frameitem' style='display:none'></View>
                    <View className={color[6] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[6] ? this.stimgcl(result[6]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[6] ? this.sttxtcl(result[6]) : ''}</View></View>
                    </View>
                  </View>
                  <View className='framerow'>
                    <View className={color[14] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[14] ? this.stimgcl(result[14]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[14] ? this.sttxtcl(result[14]) : ''}</View></View>
                    </View>
                    <View className='frameitem' style='display:none'></View>
                    <View className='frameitem' style='display:none'></View>
                    <View className={color[7] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[7] ? this.stimgcl(result[7]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[7] ? this.sttxtcl(result[7]) : ''}</View></View>
                    </View>
                  </View>
                  <View className='framerow'>
                     <View className={color[13] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[13] ? this.stimgcl(result[13]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[13] ? this.sttxtcl(result[13]) : ''}</View></View>
                    </View>
                     <View className={color[12] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[12] ? this.stimgcl(result[12]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[12] ? this.sttxtcl(result[12]) : ''}</View></View>
                    </View>
                     <View className={color[11] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[11] ? this.stimgcl(result[11]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[11] ? this.sttxtcl(result[11]) : ''}</View></View>
                    </View>
                     <View className={color[10] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[10] ? this.stimgcl(result[10]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[10] ? this.sttxtcl(result[10]) : ''}</View></View>
                    </View>
                    <View className={color[9] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[9] ? this.stimgcl(result[9]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[9] ? this.sttxtcl(result[9]) : ''}</View></View>
                    </View>
                    <View className={color[8] == 1 ? 'frameitem frameitemcheck' : 'frameitem'}>
                      <Image className='frameitemimg' src={result[8] ? this.stimgcl(result[8]) : ''}></Image>
                      <View className='frameitemflex'><View className='frameitemxnx'>{result[8] ? this.sttxtcl(result[8]) : ''}</View></View>
                    </View>
                    
                    
                  </View>
                </View>
              </View>
            </View>
           </View>
           <View className='qun-cjtite3'>
            <View className='qun-cjannu'>
              <View className='qun-cjguze'>
                <Image className='qun-cjguzeimg' mode='' src={annu[0]} onClick={this.lotteryCom.bind(this,0)}></Image>
                <View className='qun-cjno'>
                </View>
              </View>
              <View className='qun-cjanrig'>
                <View className='qun-cjguze qun-righ' onClick={this.lotteryCom.bind(this,2)}>
                  <Image className='qun-cjguzeimg' mode='' src={annu[2]}></Image>
                  <View className='qun-cjjner qun-fenshu2'>
                    <Image className='qun-cjjnerimg' mode='' src='https://minichat.g2ma.com/kedouimg/live03.png'></Image>
                    <View className='qun-cjsuzi'>{this.paytypenamecl(paymentTypeName,2,'money','住币')}</View>
                  </View>
                </View>
                <View className='qun-cjguze qun-righ1' style={this.state.iszy==3?'display:block':'display:none;'}></View>
                <View className='qun-cjguze qun-righ1' style={this.state.iszy!=3?'display:block':'display:none;'} onClick={this.lotteryCom.bind(this,3)}>
                  <Image className='qun-cjguzeimg' mode='' src={annu[3]}></Image>
                  <View className='qun-cjjner qun-fenshu3'>
                    <Image className='qun-cjjnerimg' mode='' src='https://minichat.g2ma.com/kedouimg/live03.png'></Image>
                    <View className='qun-cjsuzi'>{this.paytypenamecl(paymentTypeName,1,'money','积分')}</View>
                  </View>
                </View>
              </View>
            </View>
           </View>
           <View className='qun-cjtite4'></View>
           <View className='qun-cjtite5'>
           </View>
          </View> 
        </View>
        <View className='bg' style={this.state.iszy>=1?'display:block':'display:none;'}></View> 
        <View className={this.state.iszy==3?'qun-cjguze qun-righ1 tsrelative01':'qun-cjguze qun-righ1'} style={this.state.iszy==3?'display:block':'display:none;'} onClick={this.lotteryCom.bind(this,3)}>
          <Image className='qun-cjguzeimg' mode='' src={annu[3]}></Image>
          <View className='qun-cjjner qun-fenshu3'>
            <Image className='qun-cjjnerimg' mode='' src='https://minichat.g2ma.com/kedouimg/live03.png'></Image>
            <View className='qun-cjsuzi'>{this.paytypenamecl(paymentTypeName,1,'money','积分')}</View>
          </View>
        </View>
         
        <View className='ydcon ydcon03' style={this.state.iszy==3?'display:block;top:55%':'display:none;'}>
          <View className='ydcancle' onClick={this.closezy}>退出新手指引</View> 
        	<Text className='ydcon-text'>点击积分抽奖,进行抽奖</Text>
        	<Image className='jt' mode='widthFix' src='https://minichat.g2ma.com/kedouimg/jt.png'></Image>
        </View>
        <View className='ydcon ydcon04' style={this.state.iszy==4?'display:block;top:30%':'display:none;'}>
        	<Image className='jt' mode='widthFix' src='https://minichat.g2ma.com/kedouimg/jt.png'></Image>
        	<Text className='ydcon-text'>点击我要买单,购买抽中后的奖品</Text>
        	<View className='ydcancle' onClick={this.closezy}>退出新手指引</View> 
        </View>
      </View>
    )
  }
}